# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=miniserve
pkgver=0.20.0
pkgrel=0
pkgdesc="Quickly serve files via HTTP"
url="https://github.com/svenstaro/miniserve"
license="MIT"
arch="all !s390x !riscv64" # limited by rust/cargo
arch="$arch !ppc64le" # FTBFS
makedepends="cargo"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/svenstaro/miniserve/archive/v$pkgver/miniserve-$pkgver.tar.gz"

prepare() {
	default_prepare

	cargo fetch --locked
}

build() {
	cargo build --frozen --release

	./target/release/miniserve --print-manpage > $pkgname.1

	./target/release/miniserve --print-completions bash > $pkgname.bash
	./target/release/miniserve --print-completions fish > $pkgname.fish
	./target/release/miniserve --print-completions zsh > $pkgname.zsh
}

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/miniserve "$pkgdir"/usr/bin/miniserve

	install -Dm644 $pkgname.1 "$pkgdir"/usr/share/man/man1/$pkgname.1

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.fish "$pkgdir"/usr/share/fish/completions/$pkgname.fish
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
7dbefcf79090aceb19f706871d3cf2b71e51844e68546937d8f71d0891ff51b70e6599b0ab197ac7e32c52a49415a0dee2b7858f2a815d837f16ec5c3cb97ca6  miniserve-0.20.0.tar.gz
"
